package com.kmgames.ballsengine.scene;

import java.util.LinkedList;
import java.util.List;

import com.badlogic.gdx.graphics.Camera;
import com.kmgames.ballsengine.models.Model;
import com.kmgames.ballsengine.physics.WorldManager;
import com.kmgames.ballsengine.rendering.Renderer;

public abstract class Scene {
	protected WorldManager worldManager;
	protected Renderer renderer;
	protected Camera camera;
	private List<Model> models = new LinkedList<Model>();

	public Scene(Renderer renderer) {
		this.renderer = renderer;
		worldManager = new WorldManager();
	}

	public void render() {
		worldManager.step();

		renderer.prerender();

		if (camera != null) {
			renderer.setCamera(camera);
		}

		for (Model model : models) {
			renderer.render(model);
		}
	}

	public void AddModel(Model model) {
		models.add(model);
	}

	public abstract void updateCamera(int width, int height);

	public void dispose() {
		worldManager.dispose();
	}
}
